import request from '@/config/axios'

// 预约 VO
export interface AppointmentVO {
  id: number,
  applyNo: string  // 预约申请编号
  episodeId: number //就诊流水号
  patSrc: number
  patId: string // 患者编号
  patName: string // 患者姓名
  patGender: number // 患者性别
  patBirthday: Date // 患者生日
  patMobile: string // 患者手机
  patPhone: string // 患者电话
  patIdentityId: string // 身份证号
  patAddr: string // 患者地址
  patDeptCode: string // 患者所在科室代码
  patDeptDesc: string // 患者所在科室名称
  patWardCode: string // 患者所在病区代码
  patWardDesc: string // 患者所在病区名称
  patBedNo: string // 床号
  bookDate: Date // 预约日期
  bookTimeslot: number // 预约时间段
  bookTime: Date // 预约发生时间, 点击预约的时间
  bookCheckType: number // 预约检查类型
  paid: number //已付款
  bookSeqNum: number
}

// 预约 API
export const AppointmentApi = {
  // 查询预约分页
  getAppointmentPage: async (params: any) => {
    return await request.get({ url: `/ecg/appointment/page`, params })
  },

  // 查询预约详情
  getAppointment: async (id: number) => {
    return await request.get({ url: `/ecg/appointment/get?id=` + id })
  },

  //
  getCurAppointmentByPatIdAndCheckType: async (patId: string, checkType: number) => {
    return await request.get({ url: `/ecg/appointment/get-current-by-patient?patId=` + patId + '&checkType=' + checkType })
  },

  // 从HIS或者DB查询预约详情
  queryAndCreateAppointmentByPatId: async (patId: string) => {
    return await request.get({ url: `/ecg/appointment/query-and-create-by-patient?patId=` + patId })
  },

  // 从HIS查询预约或开单信息
  queryAppointmentFromHis: async (patId: string) => {
    return await request.get({ url: `/ecg/appointment/query-his-by-patient?patId=` + patId })
  },

  // 新增预约
  createAppointment: async (data: AppointmentVO) => {
    return await request.post({ url: `/ecg/appointment/create`, data })
  },

  // 修改预约
  updateAppointment: async (data: AppointmentVO) => {
    return await request.put({ url: `/ecg/appointment/update`, data })
  },

  // 删除预约
  deleteAppointment: async (id: number) => {
    return await request.delete({ url: `/ecg/appointment/delete?id=` + id })
  },

  // 导出预约 Excel
  exportAppointment: async (params) => {
    return await request.download({ url: `/ecg/appointment/export-excel`, params })
  },

  // 预约确认
  confirmAppointment: async (data: AppointmentVO) => {
      return await request.post({ url: `/ecg/appointment/confirm`, data })
  },

  // VIP预约确认
  confirmAppointmentVip: async (data: AppointmentVO) => {
      return await request.post({ url: `/ecg/appointment/confirm-vip`, data })
  }

}
